package com.woniu.model.gh.utils;

import cn.hutool.core.util.StrUtil;

import java.util.Map;

//处理map，判断并赋予默认值
public class MapUtil {

    //获取整数数值
    public static Integer getInteger(String keyword, Integer value, Map<String,Object> map){
        Integer number = value;

        if (!StrUtil.isEmptyIfStr(map.get(keyword)))
            number = Integer.parseInt(map.get(keyword).toString());

        return number;
    }

    public static Long getLong(String keyword, Long value, Map<String,Object> map){
        Long number = value;

        if (!StrUtil.isEmptyIfStr(map.get(keyword)))
            number = Long.valueOf(map.get(keyword).toString());

        return number;
    }

    //获取关键字
    public static String getString(String keyword, Map<String,Object> map){
        String  hospitalKeyword = "";
        if (map.get(keyword)!=null)
            hospitalKeyword = map.get(keyword).toString();
        return hospitalKeyword;
    }

}
